03 / 06

How does S3 trigger a Lambda function?

S3 Event-Driven Invocation of Lambda

Amazon S3 can trigger a Lambda function automatically in response to specific events like object uploads, deletions, or updates. This allows developers to build serverless, event-driven architectures where file operations directly invoke backend logic without manual polling.

Common S3 Events That Can Trigger Lambda
  1. 1

    s3:ObjectCreated:* – triggers when an object is uploaded or copied

  2. 2

    s3:ObjectRemoved:* – triggers when an object is deleted

  3. 3

    s3:ObjectRestore:* – triggers when an archived object is restored

  4. 4

    s3:Replication:* – triggers when an object is replicated

Steps to Configure S3 to Trigger Lambda
  1. 1

    Go to the S3 bucket in the AWS Console

  2. 2

    Select the 'Properties' tab and find 'Event notifications'

  3. 3

    Create a new event and specify the event type (e.g., ObjectCreated)

  4. 4

    Choose 'Lambda function' as the destination

  5. 5

    Select the Lambda function and grant it permission to be invoked by S3

Sample S3 Event Payload Sent to Lambda
Difficulty: 5/10
Topics: S3 event notifications, Lambda permissions, Cross-account triggers

Scenario Questions

0-2 years experience
  1. 1

    You need to run a Lambda function every time a new object is uploaded to an S3 bucket. Walk me through the steps you would take to set that up.

  2. 2

    If you accidentally set the event notification on the wrong prefix, what would happen when objects are added elsewhere in the bucket?

2-5 years experience
  1. 1

    Our team noticed that a Lambda function isn’t being invoked for certain S3 PUT events. How would you troubleshoot the issue?

  2. 2

    Explain the trade‑offs between using S3 event notifications versus S3 Object Lambda for processing new objects.

5-8 years experience
  1. 1

    Design a solution to reliably process millions of S3 object creation events per hour with Lambda, ensuring ordering and handling throttling.

  2. 2

    How would you secure cross‑account S3 to Lambda triggers while minimizing permissions and avoiding circular dependencies?

8+ years experience
  1. 1

    We are migrating a legacy data pipeline that currently uses S3 notifications to trigger a fleet of Lambda functions across multiple regions. What architectural changes would you recommend to improve scalability, observability, and fault tolerance?

  2. 2

    Discuss the long‑term maintenance implications of using S3 event notifications versus an event‑bus (e.g., EventBridge) for triggering Lambda, especially in a multi‑team environment.

Follow-up Questions

  • What limits should we be aware of when using S3‑to‑Lambda triggers?
  • How does Lambda handle retries if the function fails?
  • Can you change the trigger without redeploying the function?